package com.example.websocketclient.websocket;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class WebSocketAutoStarter implements ApplicationRunner {

    private final CustomWebSocketClien webSocketClient;

    @Autowired
    public WebSocketAutoStarter(CustomWebSocketClien webSocketClient) {
        this.webSocketClient = webSocketClient;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 启动WebSocket连接
        webSocketClient.connect();
    }
}